# 方式1
# import numpy as np
#
# a = np.array([
#     [1, 4, 2, 5],
#     [5, 6, 7, 8],
#     [9, 10, 12, 13]
# ])
#
# c = np.array([
#     [8, 7, 255, 6],
#     [5, 255, 255, 255],
#     [3, 5, 255, 255]
# ])
#
# # 使用条件索引来创建新的数组
# result = np.where(c == 255, a, c)
#
# print(result)

import numpy as np

a = np.array([
    [1, 4, 2, 5],
    [5, 6, 7, 8],
    [9, 10, 12, 13]
])

c = np.array([
    [8, 7, 255, 6],
    [5, 255, 255, 255],
    [3, 5, 255, 255]
])
# 方式3
# # 创建一个与a和c形状相同的空数组来存储结果
# result = np.empty_like(a)
#
# # 遍历数组的每个元素
# for i in range(a.shape[0]):
#     for j in range(a.shape[1]):
#         # 如果c中的元素是255，则使用a中的元素，否则使用c中的元素
#         result[i, j] = a[i, j] if c[i, j] == 255 else c[i, j]
#
# print(result)
# b = np.zeros(3,4)
# col , row = a.shape
# print(col,row)
# for i in range(col):
#     for j in range(row):
#         if(c[i][j] == 255):
#             b [i][j] = c[i][j]
#         else:
#             b[i][j]
# print(b)
# 方式2
index = c == 255
a[index] = 255
print(a)